package com.photoprint;


import java.util.ArrayList;

import com.photoprint.db.DBMethedUtil;

import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
/**
 * 购物车
 * @author Administrator
 *
 */
public class ShopActivity extends BaseActivity {
	private DBMethedUtil mDBMethedUtil;
	private LinearLayout linearLayout = null;
	private LayoutInflater inflater;
	
	private ArrayList<Photo> al;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.shop_activity);
		
		linearLayout = (LinearLayout) findViewById(R.id.linearLayout);
		inflater = getLayoutInflater();
		
		mDBMethedUtil = ((PPApplication) this.getApplication()).mDBMethedUtil;
		al = mDBMethedUtil.getShopListForNoPayNoUpdate();
		if(al != null){
			for(int i=0;i<al.size();i++){
				addItem(al.get(i));
			}
		}
	}

	@Override
	protected void onStart() {
		// TODO Auto-generated method stub
		super.onStart();
		
	}
	
	public void addItem(Photo photo){
		View item = inflater.inflate(R.layout.shop_activity_item, null);
		ImageView iv = (ImageView) item.findViewById(R.id.shop_activity_item_thumb);
		TextView size_title = (TextView) item.findViewById(R.id.shop_activity_item_size_title);
		TextView price_title = (TextView) item.findViewById(R.id.shop_activity_item_price_title);
		TextView number_title = (TextView) item.findViewById(R.id.shop_activity_item_number_title);
		
		TextView size = (TextView) item.findViewById(R.id.shop_activity_item_size);
		EditText number = (EditText) item.findViewById(R.id.shop_activity_item_number);
		TextView price = (TextView) item.findViewById(R.id.shop_activity_item_price);
		
		iv.setImageBitmap(BitmapFactory.decodeFile(photo.getThumb_data()));
		size.setText(photo.getSize());
		price.setText(photo.getPrice());
		
		LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LinearLayout.LayoutParams.FILL_PARENT, 100);
		linearLayout.addView(item, params);
	}
	
}
